package com.zyy.zyy.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zyy.zyy.entity.DataDO;
import com.zyy.zyy.dao.NoticeMapper;
import com.zyy.zyy.service.NoticeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class NoticeServiceImpl implements NoticeService {
    @Resource
    NoticeMapper noticeMapper;
    @Override
    public PageInfo<DataDO> getAllNotice(Integer pageNum, Integer pageSize) {
         //使用Mybatis分页插件
        PageHelper.startPage(pageNum,pageSize);
        //调用分页查询方法，其实就是查询所有数据，mybatis自动帮我们进行分页计算
        List<DataDO> dataDOList = noticeMapper.getAllNotice();
        return new PageInfo<>(dataDOList);
    }

    @Override
    public DataDO getNoticeDetail(DataDOKey key) {
        return noticeMapper.getNoticeDetail(key);
    }
}
